/*
 * LPSolverTest.cpp
 *
 * Copyright 2012 Fabian Wenzelmann
 *
 * This file is part of Recognition-Procedures-for-Boolean-Functions.
 *
 * Recognition-Procedures-for-Boolean-Functions is free software: you
 * can redistribute it and/or modify it under the terms of the
 * GNU General Public License as published by the Free Software Foundation,
 * either version 3 of the License, or (at your option) any later version.
 *
 * Recognition-Procedures-for-Boolean-Functions is distributed in the hope
 * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
 * Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Recognition-Procedures-for-Boolean-Functions.
 *
 * If not, see <http://www.gnu.org/licenses/>.
 */

#include <iostream>
#include <fstream>

#include <gtest/gtest.h>

#include "bfr/lpbLP/LPSolver.hpp"

#include "bfr/DIMACSParser.hpp"
#include "bfr/ClauseSet.hpp"
#include "bfr/WinderMatrix.hpp"

namespace bfr { namespace test {

TEST(LPSolverTest, sort) {
    DIMACSParser parser;
    std::ifstream in;
    in.open("test_files/LPSolverTest.dnf");
    ClauseSet *cs = parser.parse(in);
    WinderMatrix wm(cs);
    in.close();

    LPSolver::sortMatrix(wm);
    size_t entryPos = wm.size();

    EXPECT_EQ(wm[0][entryPos], 4);
    EXPECT_EQ(wm[1][entryPos], 3);
    // they have the same importance, so it doesn't matter which gets where
    EXPECT_TRUE((wm[2][entryPos] == 2) || (wm[2][entryPos] == 1)
            || (wm[2][entryPos] == 0));
    EXPECT_TRUE((wm[3][entryPos] == 2) || (wm[3][entryPos] == 1)
            || (wm[3][entryPos] == 0));
    EXPECT_TRUE((wm[4][entryPos] == 2) || (wm[4][entryPos] == 1)
            || (wm[4][entryPos] == 0));
}

// TODO
TEST(LPSolverTest, convert) {
    DIMACSParser parser;
    std::ifstream in;
    in.open("test_files/LPSolver_conversion.dnf");
    ClauseSet *cs = parser.parse(in);
    in.close();
    LPSolver solver;
    solver.convert(cs);
}

} // namespace test
} // namespace bfr
